﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PhanCongGiangDay
{
    public partial class BCHocPhan : Form
    {
        public BCHocPhan()
        {
            InitializeComponent();
        }

        private void BCHocPhan_Load(object sender, EventArgs e)
        {
            List<MHocKi> listhk = new List<MHocKi>();
            listhk = (List<MHocKi>)CHocKi.getAll();
            for (int i = 0; i < listhk.Count; i++)
            {
                string nam = listhk[i].namHoc;
                if(!cboNamHoc.Items.Contains(nam))
                {
                    cboNamHoc.Items.Add(nam);
                }
            }
            cboNamHoc.SelectedIndex = 0;          
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string namHoc = cboNamHoc.Text.Trim();
            List<MHocPhan> list = new List<MHocPhan>();
            DataSetHP dsGV = new DataSetHP();
            list = CHocPhan.getBCHP(namHoc);
            foreach (var item in list)
            {
                DataRow row = dsGV.Tables["HocPhan"].NewRow();
                row["MaHP"] = item.MAHP;
                row["TenHP"] = item.TENHP;
                row["SoTC"] = item.SOTC;
                row["SoTiet"] = item.SOTIET;
                dsGV.Tables["HocPhan"].Rows.Add(row);
            }
            CRHocPhan rp = new CRHocPhan();
            rp.SetDataSource(dsGV.Tables["HocPhan"]);
            crystalReportHP.ReportSource = rp;
            crystalReportHP.Refresh();      
        }

        
    }
}
